package com.itheima.d7_interface_demo;

import java.util.ArrayList;

public class StudentOperatorImpl2 implements StudentOperator{

    @Override
    public void printAll(ArrayList<Student> stus) {
        System.out.println("-------------------------打印学成信息---------------------------");
        int women = 0;
        int man = 0;
        for (int i = 0; i < stus.size(); i++) {
            Student s = stus.get(i);
            System.out.println(s);
            if(s.getSex().equals("男")){
                man++;
            }else{
                women++;
            }
            System.out.println("男：" + man + "  女：" + women);
        }
        System.out.println("--------------------------------------------------------------");
    }

    @Override
    public void printAvg(ArrayList<Student> stus) {
        System.out.println("--------------------------打印平均成绩--------------------------");
        int maxScore = 0;
        int minScore = 0;
        int total = 0;
        for (int i = 0; i < stus.size(); i++) {
            Student s = stus.get(i);
            total += s.getScore();
            if(s.getScore()>maxScore){
                maxScore = s.getScore();
            }
            if(s.getScore()<minScore){
                minScore = s.getScore();
            }
        }
        System.out.println("最高分：" + maxScore + "  最低分：" + minScore);
        System.out.println("平均成绩为：" + (total-maxScore-minScore) / (stus.size()-2));
    }
}
